// pages/book-read/book-read.js
Page({
    data: {
      bookPages: [],
      currentPage: 0
    },
  
    onLoad(options) {
      const index = options.id;
      // 同样，从列表页拿数据（或自己再存一份模拟数据）
      const pages = getCurrentPages();
      const listPage = pages[pages.length - 3]; // 上上个页面是列表页
      const bookList = listPage.data.bookList;
      this.setData({
        bookPages: bookList[index].pages
      });
    },
  
    handleSwipe(e) {
      this.setData({
        currentPage: e.detail.current
      });
    },
  
    prevPage() {
      if (this.data.currentPage > 0) {
        this.setData({
          currentPage: this.data.currentPage - 1
        });
      }
    },
  
    nextPage() {
      if (this.data.currentPage < this.data.bookPages.length - 1) {
        this.setData({
          currentPage: this.data.currentPage + 1
        });
      }
    }
  })
  